package com.csaba.welcome.intro;

import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor
{

	private IWorkbenchAction introAction;
	private IWorkbenchAction aboutAction;
	private IWorkbenchAction showViewMenuAction;
	private IWorkbenchAction exitAction;

	public ApplicationActionBarAdvisor( final IActionBarConfigurer configurer )
	{
		super(configurer);
	}

	@Override
	protected void makeActions( final IWorkbenchWindow window )
	{
		introAction = ActionFactory.INTRO.create(window);
		introAction.setText("Üdvözlő képernyő");
		introAction.setToolTipText("Üdvözlő képernyő megnyitása");
		exitAction = ActionFactory.QUIT.create(window);
		exitAction.setText("Kilépés");
		exitAction.setToolTipText("Kilépés a rendszerből...");
		aboutAction = ActionFactory.ABOUT.create(window);
		aboutAction.setText("Csabáról...");
		aboutAction.setToolTipText("Információk az Csaba Alkalmazásról.");
		showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
		showViewMenuAction.setText("Nézetek...");
		showViewMenuAction.setToolTipText("A rendszerben elérhető különböző nézetek listája.");
		register(introAction);
		register(exitAction);
		register(aboutAction);
		register(showViewMenuAction);
	}

	@Override
	protected void fillCoolBar( final ICoolBarManager coolBar )
	{
		final IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
		coolBar.add(new ToolBarContributionItem(toolbar, "main"));

		toolbar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
		toolbar.add(exitAction);

		//FIXME tool bar is not visible
	}

	@Override
	protected void fillMenuBar( final IMenuManager menuBar )
	{
		final MenuManager systemMenu = new MenuManager("&Rendszer", "com.csaba.menu.system");
		menuBar.add(systemMenu);
		systemMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
		systemMenu.add(new Separator("exit"));
		systemMenu.add(exitAction);

		menuBar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

		final MenuManager helpMenu = new MenuManager("&Súgó", "com.csaba.menu.help");
		menuBar.add(helpMenu);
		helpMenu.add(introAction);
		helpMenu.add(showViewMenuAction);
		helpMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
		helpMenu.add(new Separator("about"));
		helpMenu.add(aboutAction);
	}

}
